import request from '@/utils/request'

// 注册接口
export const userRegisterService = ({ username, password, repassword }) =>
  request.post('/api/reg', { username, password, repassword })

// 登录接口
export const userLoginService = ({ account, password }) =>
  request.post('/user/login', { account, password })

// 获取用户基本信息
export function userInfoApi() {
  return request.get('user/userInfo')
}

//分页条件查询用户列表
export function getEmployeeListApi(data) {
  return request({
    url: '/user/listCondition',
    method: 'post',
    data
  })
}

// 禁用/启用用户
export function disableUserApi(id, status) {
  return request({
    url: `/user/disableUser/${id}?status=${status}`,
    method: 'put'
  })
}

// 获取用户所拥有的权限列表
export function getUserDetailsApi(id) {
  return request({
    url: `/user/roleId/${id}`
  })
}

// 给用户分配角色
export function assignRoleApi(data) {
  return request({
    url: '/user/assignRole',
    method: 'put',
    data
  })
}

// 获取用户详情
export function getDetailsApi(id) {
  return request({
    url: `/user/userDetails/${id}`
  })
}

// 添加用户
export function addUserApi(data) {
  return request({
    url: `/user/add`,
    method: 'post',
    data
  })
}

// 修改用户
export function modifyUserApi(data) {
  return request({
    url: `/user/modifyUser`,
    method: 'put',
    data
  })
}

// 获取用户权限列表
export function permRangeApi() {
  return request.get('user/getPermRange')
}
